//
//  LCWShouYeCell.swift
//  MyWB
//
//  Created by 李成万 on 16/6/27.
//  Copyright © 2016年 李成万. All rights reserved.
//

import UIKit
import SnapKit
let Padding : CGFloat = 10
class LCWShouYeCell: UITableViewCell {
    
    private lazy var TopView : LCWTopView = LCWTopView()
    private lazy var bottomView : LCWBottomView = LCWBottomView()
    private lazy var middleView : LCWMiddleView = LCWMiddleView()
    
    private var bootomConstraint:Constraint?
    var status:LCWStatus?{
        didSet{
            TopView.status = status
            bottomView.status = status
           
            
            if status?.retweeted_status == nil{
                middleView.hidden = true
                bootomConstraint?.uninstall()
                bottomView.snp_makeConstraints(closure: { (make) -> Void in
                    bootomConstraint = make.top.equalTo(TopView.snp_bottom).constraint
                })
            }else{
                 middleView.status = status
                middleView.hidden = false
                bootomConstraint?.uninstall()
                bottomView.snp_makeConstraints(closure: { (make) -> Void in
                   bootomConstraint = make.top.equalTo(middleView.snp_bottom).constraint
                })
            }
            
        }
    }
    

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    func setupUI(){
        backgroundColor = RGB(237, green: 237, blue: 237)
        contentView.addSubview(TopView)
        TopView.snp_makeConstraints { (make) -> Void in
            make.leading.right.equalTo(contentView)
            make.top.equalTo(contentView).offset(8)
//            make.height.equalTo(60)
        }
        contentView.addSubview(bottomView)
        bottomView.snp_makeConstraints { (make) -> Void in
            make.leading.right.equalTo(contentView)
           bootomConstraint = make.top.equalTo(TopView.snp_bottom).constraint
            make.height.equalTo(35)
        }
        contentView.addSubview(middleView)
        middleView.snp_makeConstraints { (make) -> Void in
            make.leading.trailing.equalTo(contentView)
            make.top.equalTo(TopView.snp_bottom)
            
        }
        
        contentView.snp_makeConstraints { (make) -> Void in
            make.top.leading.trailing.equalTo(self)
            make.bottom.equalTo(bottomView)
        }
    }
 
    
    
}
